test: bool,
doctest: bool,
doc: bool,
- dest: Option<String>,
+ dest: String,
for_host: bool,
harness: bool, // whether to use the test harness (--test)
custom_build: bool,
rpath: false,
test: false,
doc: false,
- dest: None,
+ dest: "debug".to_string(),
for_host: false,
doctest: false,
custom_build: false,
env: "test".to_string(),
debug: true,
test: true,
- dest: None,
.. Profile::default()
}
}
pub fn default_bench() -> Profile {
Profile {
env: "bench".to_string(),
- opt_level: 3,
test: true,
- dest: Some("release".to_string()),
- .. Profile::default()
+ .. Profile::default_release()
}
}
Profile {
env: "release".to_string(),
opt_level: 3,
- dest: Some("release".to_string()),
+ dest: "release".to_string(),
.. Profile::default()
}
}
pub fn default_doc() -> Profile {
Profile {
env: "doc".to_string(),
- dest: None,
doc: true,
.. Profile::default()
}
pub fn opt_level(&self) -> u32 { self.opt_level }
pub fn rpath(&self) -> bool { self.rpath }
pub fn uses_test_harness(&self) -> bool { self.harness }
-
- pub fn dest(&self) -> Option<&str> {
- self.dest.as_ref().map(|d| d.as_slice())
- }
+ pub fn dest(&self) -> &str { &self.dest }
pub fn set_opt_level(mut self, level: u32) -> Profile {
self.opt_level = level;
None => dst,
};
let exe = match (bin.profile().dest(), bin.is_example()) {
- (Some(s), true) => dst.join(s).join("examples").join(bin.name()),
- (Some(s), false) => dst.join(s).join(bin.name()),
- (None, true) => dst.join("examples").join(bin.name()),
- (None, false) => dst.join(bin.name()),
+ (s, true) => dst.join(s).join("examples").join(bin.name()),
+ (s, false) => dst.join(s).join(bin.name()),
};
let exe = match exe.relative_from(config.cwd()) {
Some(path) => path,
}
impl Layout {
- pub fn new(pkg: &Package, triple: Option<&str>, dest: Option<&str>) -> Layout {
+ pub fn new(pkg: &Package, triple: Option<&str>, dest: &str) -> Layout {
let mut path = pkg.absolute_target_dir();
match triple {
Some(s) => path.push(s),
None => {}
}
- match dest {
- Some(s) => path.push(s),
- None => {}
- }
+ path.push(dest);
Layout::at(path)
}
// This is a temporary assert that ensures the consistency of the arguments
// given the current limitations of Cargo. The long term fix is to have each
// Target know the absolute path to the build location.
-fn uniq_target_dest<'a>(targets: &[&'a Target]) -> Option<&'a str> {
- let mut curr: Option<Option<&str>> = None;
+fn uniq_target_dest<'a>(targets: &[&'a Target]) -> &'a str {
+ let mut curr: Option<&str> = None;
for t in targets.iter().filter(|t| !t.profile().is_custom_build()) {
let dest = t.profile().dest();
match curr {
- Some(curr) => assert!(curr == dest),
+ Some(curr) => assert_eq!(curr, dest),
None => curr = Some(dest)
}
}
fn rustdoc(package: &Package, target: &Target,
cx: &mut Context) -> CargoResult<Work> {
let kind = Kind::Target;
- let cx_root = cx.layout(package, kind).proxy().dest().join("doc");
+ let cx_root = cx.get_package(cx.resolve.root()).absolute_target_dir()
+ .join("doc");
let mut rustdoc = try!(process(CommandType::Rustdoc, package, target, cx));
rustdoc.arg(&root_path(cx, package, target))
.cwd(cx.config.cwd())
pub fn url(&self) -> Url { path2url(self.root()) }
pub fn bin(&self, b: &str) -> PathBuf {
- self.build_dir().join(&format!("{}{}", b, env::consts::EXE_SUFFIX))
+ self.build_dir().join("debug").join(&format!("{}{}", b,
+ env::consts::EXE_SUFFIX))
}
pub fn release_bin(&self, b: &str) -> PathBuf {
}
pub fn target_bin(&self, target: &str, b: &str) -> PathBuf {
- self.build_dir().join(target).join(&format!("{}{}", b,
- env::consts::EXE_SUFFIX))
+ self.build_dir().join(target).join("debug")
+ .join(&format!("{}{}", b, env::consts::EXE_SUFFIX))
}
pub fn build_dir(&self) -> PathBuf {
{running} `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
-C metadata=[..] \
-C extra-filename=-[..] \
- --out-dir {dir}{sep}target \
+ --out-dir {dir}{sep}target{sep}debug \
--emit=dep-info,link \
- -L dependency={dir}{sep}target \
- -L dependency={dir}{sep}target{sep}deps`
+ -L dependency={dir}{sep}target{sep}debug \
+ -L dependency={dir}{sep}target{sep}debug{sep}deps`
",
running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(), url = p.url(),
assert_that(p.cargo_process("build"),
execs().with_status(0));
- let files = fs::read_dir(&p.root().join("target")).unwrap();
+ let files = fs::read_dir(&p.root().join("target/debug")).unwrap();
let mut files: Vec<String> = files.map(|e| e.unwrap().path()).filter_map(|f| {
match f.file_name().unwrap().to_str().unwrap() {
"build" | "examples" | "deps" => None,
assert_that(p.cargo_process("build"),
execs().with_status(0));
- let files = fs::read_dir(&p.root().join("target")).unwrap();
+ let files = fs::read_dir(&p.root().join("target/debug")).unwrap();
let mut files: Vec<String> = files.map(|f| f.unwrap().path()).filter_map(|f| {
match f.file_name().unwrap().to_str().unwrap() {
"build" | "examples" | "deps" => None,
{running} `rustc src[..]lib.rs --crate-name test --crate-type lib -g \
-C metadata=[..] \
-C extra-filename=-[..] \
- --out-dir {dir}[..]target \
+ --out-dir {dir}[..]target[..]debug \
--emit=dep-info,link \
- -L dependency={dir}[..]target \
- -L dependency={dir}[..]target[..]deps`
+ -L dependency={dir}[..]target[..]debug \
+ -L dependency={dir}[..]target[..]debug[..]deps`
",
running = RUNNING, compiling = COMPILING,
dir = p.root().display(),
assert_that(p.cargo_process("build").arg("--release"),
execs().with_status(0));
- assert_that(process(&p.bin("release/foo")).unwrap(),
+ assert_that(process(&p.release_bin("foo")).unwrap(),
execs().with_stdout("fast\n"));
});
let _feat = env::var("CARGO_FEATURE_FOO").unwrap();
}}
"#,
- p.root().join("target").join("build").display());
+ p.root().join("target").join("debug").join("build").display());
let p = p.file("bar/build.rs", &file_content);
{running} `rustc build.rs --crate-name build-script-build --crate-type bin \
-C prefer-dynamic -g \
--out-dir [..]build[..]foo-[..] --emit=dep-info,link \
- -L [..]target -L [..]target[..]deps \
+ -L [..]target[..]debug -L [..]target[..]deps \
--extern a=[..]liba-[..].rlib`
{running} `[..]foo-[..]build-script-build[..]`
{running} `rustc [..]lib.rs --crate-name foo --crate-type lib -g \
-C metadata=[..] -C extra-filename=-[..] \
- --out-dir [..]target --emit=dep-info,link \
- -L [..]target -L [..]target[..]deps`
+ --out-dir [..]target[..]debug --emit=dep-info,link \
+ -L [..]target[..]debug -L [..]target[..]deps`
", compiling = COMPILING, running = RUNNING).as_slice()));
});
"#);
assert_that(build.cargo_process("build"),
execs().with_status(0).with_stderr(""));
- let src = build.root().join("target");
+ let src = build.root().join("target/debug");
let lib = fs::read_dir(&src).unwrap().map(|s| s.unwrap().path()).find(|lib| {
let lib = lib.file_name().unwrap().to_str().unwrap();
lib.starts_with(env::consts::DLL_PREFIX) &&
"#);
assert_that(build.cargo_process("build"),
execs().with_status(0).with_stderr(""));
- let src = build.root().join("target");
+ let src = build.root().join("target/debug");
let lib = fs::read_dir(&src).unwrap().map(|s| s.unwrap().path()).find(|lib| {
let lib = lib.file_name().unwrap().to_str().unwrap();
lib.starts_with(env::consts::DLL_PREFIX) &&
.with_stdout(format!("\
{compiling} foo v0.5.0 ({url})
{running} `rustc src/foo.rs --crate-name foo --crate-type bin -g \
- --out-dir {dir}[..]target[..]{target} \
+ --out-dir {dir}[..]target[..]{target}[..]debug \
--emit=dep-info,link \
--target {target} \
-C ar=my-ar-tool -C linker=my-linker-tool \
- -L dependency={dir}[..]target[..]{target} \
- -L dependency={dir}[..]target[..]{target}[..]deps`
+ -L dependency={dir}[..]target[..]{target}[..]debug \
+ -L dependency={dir}[..]target[..]{target}[..]debug[..]deps`
",
running = RUNNING,
compiling = COMPILING,
path.pop();
assert_eq!(path.filename().unwrap(), b"build");
path.pop();
+ assert_eq!(path.filename().unwrap(), b"debug");
+ path.pop();
assert_eq!(path.filename().unwrap(), b"{0}");
path.pop();
assert_eq!(path.filename().unwrap(), b"target");
fn main() {
assert!(env::var("OUT_DIR").unwrap()
- .contains("target/build/d1-"),
+ .contains("target/debug/build/d1-"),
"bad: {:?}", env::var("OUT_DIR"));
}
"#);
assert_that(cargo_process("build").cwd(&paths::root().join("foo")),
execs().with_status(0));
- assert_that(&paths::root().join(&format!("foo/target/foo{}",
+ assert_that(&paths::root().join(&format!("foo/target/debug/foo{}",
env::consts::EXE_SUFFIX)),
existing_file());
});
-C metadata=[..] \
-C extra-filename=-[..] \
-C rpath \
- --out-dir {dir}{sep}target \
+ --out-dir {dir}{sep}target{sep}debug \
--emit=dep-info,link \
- -L dependency={dir}{sep}target \
- -L dependency={dir}{sep}target{sep}deps`
+ -L dependency={dir}{sep}target{sep}debug \
+ -L dependency={dir}{sep}target{sep}debug{sep}deps`
",
running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(),
assert_that(p.cargo_process("run"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
-{running} `target{sep}foo`
+{running} `target{sep}debug{sep}foo`
hello
",
compiling = COMPILING,
assert_that(p.cargo_process("run").arg("--bin").arg("a"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
-{running} `target{sep}a`
+{running} `target{sep}debug{sep}a`
hello a.rs
",
compiling = COMPILING,
assert_that(p.cargo("run").arg("--bin").arg("b"),
execs().with_status(0).with_stdout(format!("\
-{running} `target{sep}b`
+{running} `target{sep}debug{sep}b`
hello b.rs
",
running = RUNNING,
assert_that(p.cargo_process("run").arg("--example").arg("a"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
-{running} `target{sep}examples{sep}a`
+{running} `target{sep}debug{sep}examples{sep}a`
example
",
compiling = COMPILING,
assert_that(p.cargo_process("run"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
-{running} `target{sep}main`
+{running} `target{sep}debug{sep}main`
hello main.rs
",
compiling = COMPILING,
-g \
-C metadata=[..] \
-C extra-filename=[..] \
- --out-dir {dir}{sep}target{sep}deps \
+ --out-dir {dir}{sep}target{sep}debug{sep}deps \
--emit=dep-info,link \
- -L dependency={dir}{sep}target{sep}deps \
- -L dependency={dir}{sep}target{sep}deps`
+ -L dependency={dir}{sep}target{sep}debug{sep}deps \
+ -L dependency={dir}{sep}target{sep}debug{sep}deps`
{compiling} foo v0.0.1 ({url})
{running} `rustc examples{sep}a.rs --crate-name a --crate-type bin \
-g \
- --out-dir {dir}{sep}target{sep}examples \
+ --out-dir {dir}{sep}target{sep}debug{sep}examples \
--emit=dep-info,link \
- -L dependency={dir}{sep}target \
- -L dependency={dir}{sep}target{sep}deps \
- --extern bar={dir}{sep}target{sep}deps{sep}libbar-[..].rlib`
-{running} `target{sep}examples{sep}a`
+ -L dependency={dir}{sep}target{sep}debug \
+ -L dependency={dir}{sep}target{sep}debug{sep}deps \
+ --extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar-[..].rlib`
+{running} `target{sep}debug{sep}examples{sep}a`
slow1
slow2
",
use std::old_io::Command;
#[test]
fn test_test() {
- let status = Command::new("target/foo").status().unwrap();
+ let status = Command::new("target/debug/foo").status().unwrap();
assert!(status.matches_exit_status(1));
}
"#);